package com.xing.controller;

import com.xing.Utils.Result;
import com.xing.dto.LiveReportDTO;
import com.xing.entity.LiveReportEntity;
import com.xing.service.LiveReportService;
import com.xing.utils.PageData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "举报消息处理服务")
@RestController
@RequestMapping(value = "report")
public class LiveReportController {

    @Autowired
    private LiveReportService reportService;


    @Operation(summary = "查询所有举报信息")
    @GetMapping(value = "listAllReport")
    @PreAuthorize("hasAnyAuthority('admin')")
    public Result listAllReport() {
        List<LiveReportEntity> reportEntityList = reportService.listAllReport();
        return new Result().ok(reportEntityList);
    }


    @Operation(summary = "分页获取举报信息")
    @GetMapping(value = "/pageReport")
    @PreAuthorize("hasAnyAuthority('admin')")
    public Result pageReport(@RequestParam Integer pageNum, @RequestParam Integer pageSize) {
        PageData<LiveReportDTO> liveReportPage = reportService.pageReport(pageNum, pageSize);
        return new Result().ok(liveReportPage);
    }


    @Operation(summary = "处理举报")
    @PostMapping(value = "handleReport")
    @PreAuthorize("hasAnyAuthority('admin')")
    public Result handleReport(@RequestBody LiveReportDTO dto) {
        return reportService.handleReport(dto);
    }


    @Operation(summary = "新增举报")
    @PostMapping(value = "addReport")
    public Result AddReport(@RequestBody LiveReportDTO dto) {
        return reportService.addReport(dto);
    }


}
